<template>
    <div class="loginBox">
        <div class="banner">
            <h1>社交、聊天、直播后台管理系统</h1>
        </div>
        <div class="login">
            <form action="#">
                <div class="inp">
                    <label for="username">
                        用户名：
                    </label>
                    <input type="text" name="username" id="username" placeholder="请输入用户名" v-model="username">
                </div>
                <div class="inp">
                    <label for="pwd">
                        密码：
                    </label>
                    <input type="password" name="pwd" id="pwd" placeholder="请输入密码" v-model="pwd">
                </div>
                <div class="btn">
                        <button type="button" @click="login" :plain="true">登录</button>   
                </div>
                
            </form>
        </div>
    </div>
</template>

<script>

    export default {
        name:'Login',
        data(){
            return{
                username:'',
                pwd:''
            }
        },
        methods:{
            login(){
                this.$axios({
                    method:'post',
                    url:this.$api.login.userLogin,
                    data:{
                        username:this.username,
                        pwd:this.pwd
                    }
                })
                .then(res=>{
                    if(res.data == '登录成功'){
                        this.$router.replace('/Home/WorkTable')
                        
                    }else{
                        this.$message.error('用户名或密码错误！');
                    }
                })
                .catch(err=> {
                    console.log(err);
                })
            }
        }
    }


</script>

<style scoped lang="less">
    @back: #015478;
    .inpStyle{
        width: 100%;
        margin-top: 20px;
        display: flex;
        align-items: center;
    }
    
    *{
        margin: 0;
        padding: 0;
    }
     .banner{
        width: 100%;
        height: 300px;
        background: @back;
        display: flex;
        justify-content: center;
        align-items: center;
        color: white;
     }
     .login{
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 30px;  
        >form{
            width: 280px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-content: center;
            >.inp{
                .inpStyle;
                justify-content: space-between;

            }
        }
     }
     input{
        width: 200px;
        height: 25px;
        outline: none;
        padding: 4px;
     }
     .btn{
        .inpStyle;
        justify-content: flex-end;
     }
     button{
        padding: 8px 15px;
        border: none;
        background: @back;
        color: white;
        border-radius: 3px;
        font-size: 16px;
        display: flex;
        justify-content: center;
     }
</style>